﻿
Imports System.IO
Imports xmlctrl
Imports xhtmlctrl
Imports webctrl

Public Class roomSelector
    Inherits div

    Public Sub New(ByVal page As xhtmlpage, Optional ByVal buff As MemoryStream = Nothing)
        MyBase.New(buff)

        Dim context As httpContext = Nothing
        context = httpServer2.currentContext()

        Dim div As div = Nothing
        div = context.createControl(New div())
        div.text = context.string(stringId.SELECT_STOROOM)
        addchild(div)

        Dim ul As ul = Nothing
        ul = context.createControl(New ul())
        addchild(ul)

        Dim li As li = Nothing
        Dim i As Int64
        For i = 0 To rooms.size() - 1
            li = context.createControl(New colorli(page, buff))
            ul.addchild(li)

            Dim a As a = Nothing
            a = context.createControl(New a())
            a.text = rooms(i).name + " @ " + displayHostPort(rooms(i).host, rooms(i).port)
            a.href = roomstatus.generatelink(rooms(i).host, rooms(i).port)
            li.addchild(a)
        Next

        li = context.createControl(New colorli(page, buff))
        ul.addchild(li)

        div = context.createControl(New div())
        div.text = context.string(stringId.INPUT_STOROOM)
        li.addchild(div)

        Dim form As form = Nothing
        form = context.createControl(New form())
        form.action = strmid(roomstatus._pathidentity, strlen(network.pathSeperator))
        li.addchild(form)

        Dim label As label = Nothing
        label = context.createControl(New label())
        label.text = context.string(stringId.INPUT_HOST)
        form.addchild(label)

        Dim input As input = Nothing
        input = context.createControl(New input())
        input.type = xhtmlctrl.input.type_enum.text
        input.name = query.host
        form.addchild(input)

        label = context.createControl(New label())
        label.text = context.string(stringId.INPUT_PORT)
        form.addchild(label)

        input = context.createControl(New input())
        input.type = xhtmlctrl.input.type_enum.text
        input.name = query.port
        form.addchild(input)

        input = context.createControl(New input())
        input.type = xhtmlctrl.input.type_enum.submit
        input.value = context.string(stringId.INPUT_STOROOM_SUBMIT)
        form.addchild(input)
    End Sub
End Class
